<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="Bookmark" href="/favicon.ico" >
<link rel="Shortcut Icon" href="/favicon.ico" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="/static/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="/static/h-ui.admin/css/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>订单列表</title>
<style type="text/css">
	.pagelist ul li{display:inline-block;width:20px;height:20px;text-align:center;}
	.pagelist ul li a{width:20px;height:20px;}
	.pagelist ul li.active{background-color:#ccc !important;color:#fff;}
</style>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 内容管理 <span class="c-gray en">&gt;</span> 订单列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	<form class="text-c"> 日期范围：
		
		<input name="fromtime" type="text" {literal} onfocus="WdatePicker({ maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}' })" {/literal} id="datemin" class="input-text Wdate" style="width:120px;" value="{$fromtime}">
		-
		<input name="totime" type="text" {literal} onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d' })" {/literal} id="datemax" class="input-text Wdate" style="width:120px;" value="{$totime}">
		
		<input type="text" class="input-text" style="width:250px" placeholder="输入订单号/产品/姓名/电话/地址" id="key" name="key" value="{$key}">
		<button type="submit" class="btn btn-success" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
	</form>
	<div class="cl pd-5 bg-1 bk-gray mt-20">
	</div>
	<script type="text/javascript" src="/static/lib/jquery/1.9.1/jquery.min.js"></script> 
	<script type="text/javascript">
		function shuaxin(id){
			$.ajax({
		        type:"get",
		        url:'timeoutstate',
		        dataType:"json",
		        data:{id:id},
		        success:function(res){
		        	if(res.code==200){
			        	window.location.reload();
			        }
		        }
		    })
		}
		function clock(timeid,time){
			var today=new Date();//当前时间
		  	var shenyu=time*1000-today.getTime();//倒计时毫秒数
		  	if(shenyu>=0){
			    shengyuD=parseInt(shenyu/(60*60*24*1000));//转换为天
			    D=parseInt(shenyu)-parseInt(shengyuD*60*60*24*1000);//除去天的毫秒数
			    shengyuH=parseInt(D/(60*60*1000));//除去天的毫秒数转换成小时
			    H=D-shengyuH*60*60*1000;//除去天、小时的毫秒数
			    shengyuM=parseInt(H/(60*1000));//除去天的毫秒数转换成分钟
			    M=H-shengyuM*60*1000;//除去天、小时、分的毫秒数
			    S=parseInt((shenyu-shengyuD*60*60*24*1000-shengyuH*60*60*1000-shengyuM*60*1000)/1000);//除去天、小时、分的毫秒数转化为秒
			    document.getElementById(timeid).innerHTML=(shengyuD+"天"+shengyuH+"小时"+shengyuM+"分"+S+"秒"+"<br>");
			    setTimeout(function(){
					clock(timeid,time)
			    },500)
		  	}else{
		  		shuaxin(timeid.substring(4));
		  	}
		}
	</script>
	<table class="table table-border table-bordered table-bg">
		<thead>
			<tr>
				<th scope="col" colspan="14">订单列表<span class="r">共有数据：<strong>{:count($lists)}</strong> 条</span></th>
			</tr>
			<tr class="text-c">
				<th width="40">ID</th>
				<th width="100">订单号</th>
				<th width="100">商品</th>
				<th width="100">参数</th>
				<th width="50">单价</th>
				<th width="50">金额</th>
				<th width="80">姓名</th>
				<th width="100">电话</th>
				<th width="150">地址</th>
				<th width="130">时间</th>
				<th width="100">操作</th>
			</tr>
		</thead>
		<tbody>
			{foreach $list as $key=>$value }
			<tr class="text-c" id="val_{$value.id}">
				<td>{$value.id}</td>
				<td>{$value.paycode}</td>
				<td>{$value.title}</td>
				<td>{$value.parm}</td>
				<td>{$value.price}元</td>
				<td>{$value.payfee}元</td>
				<td>{$value.uname}</td>
				<td>{$value.uphone}</td>
				<td>{$value.uaddress}</td>
				<td>{:date('Y-m-d H:i:s',$value.time)}</td>
				<td class="td-status" id="state_nf{$value.id}">

					{if $value.sub==1}
						<a href="javascript:;" onclick="orderdetail('订单详情','{:url('orderdetail')}?id={$value.id}','800','500')" class="label label-success radius">订单详情</a>
					{elseif $value.sub==2}
						<a href="javascript:;" onclick="orderdetail('订单详情','{:url('orderdetail')}?id={$value.id}','800','500')" class="label label-success radius">订单详情(s)</a>
					{/if}
					{if $value.paystate==1}
						<span class="label label-info radius">待付款</span>
					{elseif $value.paystate==2}
						<span class="label label-warning radius" style="cursor:pointer;" id="toexpress">待发货<input type="hidden" value="{$value['id']}"></span>
					{elseif $value.paystate==3}
					<?php  $a = $value['id']; $b=$value['etime']; ?>
						<span id="time{$value['id']}"></span>
						<script type="text/javascript">
							clock('time{$a}','{$b}');
						</script>
						<input type="hidden" name="time" class="hide_time" value="{$value['id']}">
						<span class="label label-primary radius">待收货</span>
					{elseif $value.paystate==4}
						<span class="label label-success radius">已完成</span>
					{elseif $value.paystate==5}
						{if $value['salesbacktate']==5}
						<span class="label label-success radius" style="cursor:pointer;">已退款</span>
						{else}
						<span class="label label-default radius">已取消</span>
						{/if}
					{elseif $value.paystate==6}
						<span class="label label-default radius">已删除</span>
					{elseif $value.paystate==7}
						{if $value['backstate']==1}
						<span class="label label-danger radius" style="cursor:pointer;" onClick="refuse(this,{$value.id},'待发货(仅退款)');">同意退款</span>
						{elseif $value['backstate']==2}
						<span class="label label-danger radius" style="cursor:pointer;" onClick="refuse(this,{$value.id},'已发货(仅退款)');">同意退款</span>
						{elseif $value['backstate']==3}
							{if $value['salesbacktate']==1}
								<span class="label label-danger radius" style="cursor:pointer;" onClick="applyrefuse(this,{$value.id},'已发货(退货退款)');">同意申请</span>
							{elseif $value['salesbacktate']==3}
								<span class="label label-default radius">等待中</span>
							{elseif $value['salesbacktate']==6}
								<span class="label label-danger radius" style="cursor:pointer;" onClick="refuse(this,{$value.id},'已返货(退货退款)');">退货退款</span>
							{/if}
						{/if}
					{/if}
				</td>
			</tr>
      		{/foreach}
		    <tr>
		        <td colspan="14">
			        <div class="pagelist"  style="text-align: right;">
			        	{$list->render()|raw}
			        </div>
		        </td>
		    </tr>
		</tbody>
	</table>
</div>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="/static/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="/static/h-ui/js/H-ui.min.js"></script> 
<script type="text/javascript" src="/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/static/lib/My97DatePicker/4.8/WdatePicker.js"></script> 
<script type="text/javascript" src="/static/lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="/static/lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript">
$(".pagelist").on("click",".pagination a",function(){
  var url=$(this).attr("href");
  getPage(url);
  return false;
});
function getPage(url)
{
  $.get(url, function(data){
    $("body").html(data);

  });
}
/*退款*/
function refuse(obj,id,msg){
	layer.confirm('确认放款?'+msg+'?',function(index){
		$.ajax({
			type: 'POST',
			url: '{:url("refusepayfee")}',
			data:{id:id},
			success: function(data){
		    	if(data.code==200){
					layer.msg('已放款!',{icon:1,time:1000});
		            var a='<span class="label label-success radius" style="cursor:pointer;">已退款</span>'
		            $('#state_nf'+id).html(a);
		            return false;
		    	}
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
}
/*退款申请*/
function applyrefuse(obj,id,msg){
	layer.confirm('同意申请？'+msg+'?',function(index){
		$.ajax({
			type: 'POST',
			url: '{:url("applyrefuse")}',
			data:{id:id},
			success: function(data){
		    	if(data.code==200){
					layer.msg('已同意!',{icon:1,time:1000});
		            var a='<span class="label label-success radius" style="cursor:pointer;">等待中</span>'
		            $('#state_nf'+id).html(a);
		            return false;
		    	}
			},
			error:function(data) {
				console.log(data.msg);
			},
		});		
	});
}
/*详情页*/
function orderdetail(title,url,w,h){
	layer_show(title,url,w,h);
}
$('#toexpress').on('click', function(){
    let order_id = $(this).children().val()
	layer.open({
		type:1,
		title:'快递信息',
		skin:'layui-layer-rim',
		area:['auto','auto'],
		content:'<table style="border-collapse:collapse;"><tbody>'
	        +'<tr>'
	            +'<td style="border:1px solid #ccc;font-weight:bolder;text-align:right;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;快递公司：</td>'
	            +'<td style="border:1px solid #ccc;text-align:left;padding-left:3px;"><input style="width:80%;border:1px solid #ddd;border-radius:3px;" type="text" name="express" value=""></td>'
	        +'</tr>'
	        +'<tr>'
	            +'<td style="border:1px solid #ccc;font-weight:bolder;text-align:right;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;快递单号：</td>'
	            +'<td style="border:1px solid #ccc;text-align:left;padding-left:3px;"><input style="width:80%;border:1px solid #ddd;border-radius:3px;" type="text" name="expressnum" value=""></td>'
	        +'</tr>'
	    +'</tbody></table>',
		btn:['确认','取消'],
		btn1: function (index,layero) {
			let express = $('input[name=express]').val()
			let expressnum = $('input[name=expressnum]').val()
			$.ajax({
				type : 'post',
				url  :  'expressinfo',
				dataType:"json",
				data : {order_id:order_id,express:express,expressnum:expressnum},
				success:function(data){
					if(data.code==200){
						layer.msg('成功!',{icon:1,time:1000});
						setTimeout("location.reload()",1000);
					}else{
						layer.msg(data.msg,{icon:2,time:2000});
					}
				}
			});
    	},
    	btn2:function (index,layero) {
    	}
	});
});
</script>
</body>
</html>